package com.shaozi.nc.mq.substance;

import org.apache.log4j.Logger;
import org.json.JSONObject;

import com.shaozi.data.mq.business.base.SourceTypeConsts;
import com.shaozi.data.mq.business.bean.MQExchangeRuleBean;
import com.shaozi.data.mq.business.bean.MQPushItem;
import com.shaozi.data.mq.business.bus.substance.BasePushSubstanceHandler;
import com.shaozi.lib.throwable.SzException;
import com.shaozi.nc.mq.bean.base.BizBaseBean;
import com.shaozi.nc.mq.bean.platform.PermissionChangeBean;
import com.shaozi.nc.mq.bean.platform.PlatformBean;
import com.shaozi.nc.mq.bean.platform.RoleChangeBean;
import com.shaozi.nc.mq.bean.platform.UserLeaveApprovalBean;

/**
 * Created by lotrv on 2016/7/20.
 */
public class PlatformPushSubstance extends BasePushSubstanceHandler {

	private final Logger logger = Logger.getLogger(PlatformPushSubstance.class);

	@Override
	protected void onExchangeBiz(MQExchangeRuleBean pushData, MQPushItem pushItem, JSONObject jsonObj)
			throws SzException {
		switch (pushItem.getSourceType()) {
		case SourceTypeConsts.OA.Platform.User_Approval:
			exchangeBiz(pushData, jsonObj, PlatformBean.class);
			break;
		case SourceTypeConsts.OA.Platform.User_Leave_Approval:
			exchangeBiz(pushData, jsonObj, UserLeaveApprovalBean.class);
			break;
		case SourceTypeConsts.OA.Platform.desert:
			exchangeBiz(pushData, jsonObj, BizBaseBean.class);
			break;
		case SourceTypeConsts.OA.Platform.Work_Day_Change:
			exchangeBiz(pushData, jsonObj, PlatformBean.class);
			break;
		case SourceTypeConsts.OA.Platform.Role_Change:
			exchangeBiz(pushData, jsonObj, RoleChangeBean.class);
			break;
		case SourceTypeConsts.OA.Platform.Permission_Change:
			exchangeBiz(pushData, jsonObj, PermissionChangeBean.class);
			break;
		default:
			pushData.setBiz(null);
			break;
		}
	}

}
